<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>详情</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../static/css/typo.css">
    <link rel="stylesheet" href="../static/css/animate.css">
    <link rel="stylesheet" href="../static/lib/prism/prism.css">
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css">
    <link rel="stylesheet" href="../static/css/index.css">
</head>
<body>
<!--导航栏-->
    <nav th:replace="_fragments :: menu(1)" class="ui inverted attached segment m-padding-tb-mini">
        <div class="ui container">
            <div class="ui inverted secondary stackable menu">
                <h2 class="ui teal header item">blog</h2>
                <a href="#" class="m-item item m-mobile-hide"><i class="home icon"></i>首页</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="clone icon"></i>归档</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="info icon"></i>关于我</a>
                <div class="m-item right item m-mobile-hide">
                    <div class="ui icon inverted transparent input">
                        <input type="text" placeholder="搜索">
                        <i class="search link icon"></i>
                    </div>
                </div>
            </div>
        </div>
<!--        导航图标-->
        <a href="#" class="ui menu toggle black icon button m-menubar m-mobile-show">
            <i class="sidebar icon"></i>
        </a>

    </nav>
<!--中间内容-->
    <div class="m-padding-tb-massive m-container">
       <div class="ui container">
<!--           头部-->
           <div class="ui top attached segment">
               <div class="ui horizontal link list">
                   <div class="item">
                       <img src="https://picsum.photos/id/1032/100/100" alt="" class="ui avatar image" th:src="@{${blog.user.avatar}}">
                       <div class="content"><a href="#" class="header" th:text="${blog.user.nickname}">清风丶Yocky</a></div>
                   </div>
                   <!--                                                发布日期-->
                   <div class="item">
                       <i class="calendar icon"></i> <span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">2020-09-25</span>
                   </div>
                   <!--                                                浏览次数-->
                   <div class="item">
                       <i class="eye icon"></i> <span th:text="${blog.views}">3333</span>
                   </div>
               </div>
           </div>
<!--           图片区域-->
           <div class="ui attached segment">
               <img src="https://picsum.photos/id/1032/400/200" alt="" class="ui fluid rounded image" th:src="@{${blog.firstPicture}}">
           </div>
<!--           内容区域-->
           <div class="ui attached padded segment">
               <div class="ui right aligned basic segment">
                   <div class="ui orange basic label" th:text="${blog.flag}">原创</div>
               </div>

               <h2 class="ui center aligned header" th:text="${blog.title}">这是一个标题</h2><br/>
               <div id="content" class="typo typo-selection js-toc-content m-padding-lr-big-responsive" th:utext="${blog.content}">

               </div>

<!--               标签-->
               <div class="m-padding-lr-big-responsive m-padding-tb">
                   <div class="ui basic teal left pointing label" th:each="tag : ${blog.tags}" th:text="${tag.name}">方法论</div>
               </div>

               <div class="ui center aligned basic segment">
                   <button id="payButton" class="ui basic orange basic circular button">赞赏</button>
               </div>
               <div class="ui payQR flowing popup transition hidden">
                   <div class="ui orange basic label">
                       <div class="ui images m-font-show">
                           <div class="image">
                               <img src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}" alt="" class="ui rounded bordered image" style="width: 120px;">
                               <div>支付宝</div>
                           </div>
                           <div class="image">
                               <img src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}" alt="" class="ui rounded bordered image" style="width: 120px;">
                               <div>微信</div>
                           </div>
                       </div>
                   </div>
               </div>
           </div>
               
               

               
<!--           博客信息-->
           <div class="ui attached positive message">
               <div class="ui middle aligned grid">
                   <div class="eleven wide column">
                       <ul class="list">
                           <li>作者: <span th:text="${blog.user.nickname}">清风丶Yocky</span></li>
                           <li>发表时间: <span th:text="${#dates.format(blog.updateTime, 'yyyy-MM-dd HH:mm')}">2020-9-25 17:00</span></li>
                           <li>版权声明: 自由转载-非商用-非衍生-保持署名</li>
                           <li>公众号转载: 请在文末添加作者公众号二维码</li>
                       </ul>
                   </div>
                   <div class="five wide column">
                       <img src="../static/images/wechat.jpg" alt="" th:src="@{/images/wechat.jpg}" class="ui right floated rounded bordered image" style="width:110px;">
                   </div>
               </div>
           </div>
<!--           留言区域-->
           <div class="ui bottom attached segment ">
<!--               留言区域列表-->
               <div id="comment-container" class="ui teal segment">
                   <div th:fragment="commentList">
                       <div class="ui comments" style="max-width: 100%">
                           <h3 class="ui dividing header">评论</h3>
                           <div class="comment" th:each="comment : ${comments}">
                               <a class="avatar">
                                   <img src="https://picsum.photos/id/1032/800/400" th:src="@{${comment.avatar}}">
                               </a>
                               <div class="content">
                                   <a class="author" th:text="${comment.nickname}">Matt</a>
                                   <div class="metadata">
                                       <span class="date" th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">今天下午 5:42</span>
                                   </div>
                                   <div class="text" th:text="${comment.content}">太赞了！ </div>
                                   <div class="actions">
                                       <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}" onclick="reply(this)">回复</a>
                                   </div>
                               </div>
                           </div>


                       </div>
                   </div>

               </div>
               <!---------------------评论输入----------------------->
               <div id="comment-form" class="ui form">
                   <input type="hidden" name="blog.id" th:value="${blog.id}">
                   <input type="hidden" name="parentComment.id" value="-1">
                   <div class="field">
                       <textarea name="content" placeholder="请输入评论信息"></textarea>
                   </div>
                   <div class="fields">
                       <div class="field m-mobile-wide m-margin-bottom-mini">
                           <div class="ui left icon input">
                               <i class="user icon"></i>
                               <input type="text" name="nickname" placeholder="姓名">
                           </div>
                       </div>
                       <div class="field m-mobile-wide m-margin-bottom-mini">
                           <div class="ui left icon input">
                               <i class="mail icon"></i>
                               <input type="text" name="email" placeholder="邮箱">
                           </div>
                       </div>
                       <div class="field m-mobile-wide m-margin-bottom-mini">
                           <button id="commentpost-btn" type="button" class="ui teal button m-mobile-wide"><i class="edit icon"></i>发布</button>
                       </div>
                   </div>
               </div>
               <!-----                评论输入结束                 -->
           </div>
       </div>

    </div>


    <div class="m-padding-lr m-padding-tb m-fix-absolute m-right-bottom">
        <div class="ui vertical icon buttons">
            <button type="button" class="ui toc teal button">目录</button>
            <a href="#comment-container" type="button" class="ui teal button">留言</a>
            <button class="ui wechat icon button"><i class="weixin icon"></i></button>
            <div id="toTop-button" class="ui teal icon button"><i class="chevron up icon"></i></div>
        </div>
    </div>
    <div class="ui toc-container flowing popup transition hidden" style="width: 250px;">
        目录

        <ol class="js-toc">

        </ol>
    </div>

    <div id="qrcode" class="ui weixin-QR flowing popup transition hidden m-padded-mini" style="width: 130px">

    </div>

<!--底部内容-->
    <footer th:replace="_fragments :: footer" class="ui inverted vertical segment m-padding-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted devided stackable grid">
                <div class="three wide column">
                    <div class="item">
                        <img src="../static/images/wechat.jpg" class="ui rounded image" alt="" style="width: 110px">
                    </div>
                </div>
                <div class="four wide column">
                    <h4 class="ui inverted header m-opacity-mini">最新博客</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item m-opacity-mini">用户故事</a>
                        <a href="#" class="item m-opacity-mini">sad</a>
                        <a href="#" class="item m-opacity-mini">asd</a>
                    </div>
                </div>
                <div class="four wide column">
                    <h4 class="ui inverted header m-opacity-mini">联系我</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item m-opacity-mini">Email:1324810595@qq.com</a>
                        <a href="#" class="item m-opacity-mini">QQ:1324810595</a>
                    </div>
                </div>
                <div class="five wide column">
                    <h4 class="ui inverted header m-opacity-mini">asdasd</h4>
                    <p class="m-text-thin m-text-space m-opacity-mini">sadasdasdasd</p>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <p class="m-text-thin m-text-space m-opacity-tini">Copyright</p>
        </div>
    </footer>


<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<script src="../static/lib/prism/prism.js"></script>
<script src="../static/lib/tocbot/tocbot.js"></script>
<script src="../static/lib/qrcode/qrcode.js"></script>
<script src="../static/lib/scrollTo/jquery.scrollTo.js"></script>

<script th:inline="javascript">
    $('.ui.form').form({
        fields: {
            content : {
                identifier : 'content',
                rules: [{
                    type : 'empty',
                    prompt: '标题:请输入博客标题'
                }]
            },
            nickname : {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '内容:请输入博客内容'
                }]
            },
            email : {
                identifier: 'email',
                rules: [{
                    type: 'empty',
                    prompt: '内容:请选择分类'
                }]
            }
        }});

    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('#payButton').popup({
        popup : $('.payQR.popup'),
        on : 'click',
        position : 'bottom center'
    });
    //初始化tocbot
    tocbot.init({
        tocSelector: '.js-toc',
        contentSelector: '.js-toc-content',
        headingSelector: 'h1, h2, h3'
    });

    $('.toc.button').popup({
        popup : $('.toc-container.popup'),
        on : 'click',
        position : 'left center'
    });

    $('.wechat').popup({
        popup : $('.weixin-QR'),

        position : 'left center'
    });
    //生成当前网页二维码
    var serurl = "localhost:8080";//域名
    var url = /*[[@{/blog/{id}(id=${blog.id})}]]*/"";
    var qrcode = new QRCode("qrcode", {
        text: serurl+url,
        width: 100,
        height: 100,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });

    $('#toTop-button').click(function () {
        $(window).scrollTo(0,300)
    })

    $('#commentpost-btn').click(function () {
        var boo = $('.ui.form').form('validate form');
        if (boo){
            console.log("校验成功");
            postData();
        }else {
            console.log("校验失败");
        }
    });
    function postData() {
        $("#comment-container").load(/*[[@{/comments}]]*/"",{
            "parentComment.id" : $("[name='parentComment.id']").val(),
            "blog.id" : $("[name='blog.id']").val(),
            "nickname" : $("[name='nickname']").val(),
            "email" : $("[name = 'email']").val(),
            "content" : $("[name = 'content']").val()
        },function (responseTxt, statusTxt, xhr) {
            $(window).scrollTo($('#comment-container'),500);
            clearContent();
        });
    }

    function clearContent() {
        $("[name = 'content']").val('');
        $("[name='parentComment.id']").val(-1);
        $("[name='content']").attr("placeholder","请输入评论信息");
    }
    function reply(obj) {
        var id = $(obj).data("commentid");
        var nickname = $(obj).data("commentnickname");

        $("[name='content']").attr("placeholder","@"+commentNickname).focus();
        $("[name='parentComment.id']").val(commentId);
        $(window).scrollTo($('#comment-form'),500);
    }

</script>
</body>
</html>